<template>
	<view>
		<view class="uni-form-item ">
			<view class="title">撰写评论</view>
			<textarea  placeholder="请输入评论内容..." auto-height v-model="this.content"/>
			<button type="submit" @click="commentSubmit">发布</button>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				fid:0,
				uid:0,
				cmtype:'',
				content:''
			}
		},
		methods:{
			commentSubmit(){
				var that=this
				uni.showModal({
				    title: '提示',
				    content: '是否确认发布？',
				    success: function (res) {
				        if (res.confirm) {
				           that.Submit()
						   uni.switchTab({
						   	url:'/pages/index/index'
						   })						   							  
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			},
			async Submit(){
				const res=await this.$myRequest({
					url:'/'+this.cmtype+'Article/api/addComment/id='+this.fid+'&content='+this.content+'&uid='+this.uid,				
				})
				console.log(res)
			}
		},
		onLoad(options) {
			console.log(options)
			this.cmtype=options.type
			this.fid=options.fid
			this.uid=options.uid
		}
	}
</script>

<style lang="less">
	page{
		padding-top:50rpx;
	}
	.uni-form-item{
		padding-left: 40rpx;
		padding-right: 40rpx;
		justify-content: space-between;
		align-items: center;
		margin-bottom:30rpx ;
		textarea{
			background: #fff;
			width:100%;
			min-height: 300rpx;
			border: 1px solid #f8f8f8;
			border-radius: 10rpx;
			float: right;
			margin-top: 20rpx;
			margin-bottom: 15rpx;
			
		}
		button{
			width:200rpx;
		}
		}
</style>
